<?php
/**
 * 设置用户权限
 */
include_once 'common_mbs.inc.php';
include_once 'smarty.inc.php';

$admin_index_obj= new osgh_admin_index_tbl_cls();
$admin_info = $admin_index_obj->getAdminIndexInfo($_ADMIN_ID);

$op = trim($_REQUEST['op']);
if ( $op == "save")
{
	$real_name = trim($_POST['real_name']);
	$pwd_old = trim($_POST['pwd_old']);
	$pwd = trim($_POST['pwd']);
	$pwd2 = trim($_POST['pwd2']);
	
	if( strlen($pwd_old)<1 || strlen($pwd)<1 || strlen($pwd2)<1 )
	{
		tcmc_cls::ShowMsg("请填写完整！", "user_set.php");
	}
	
	if( $pwd!=$pwd2 )
	{
		tcmc_cls::ShowMsg("两次密码不一致！", "user_set.php");
	}
	
	$pwd_old_md5 = md5($pwd_old);
	if( $admin_info['password']!=$pwd_old_md5 )
	{
		tcmc_cls::ShowMsg("旧密码错误！", "user_set.php");
	}
	$data = array(
		'password' => md5($pwd),
	);
	if( strlen($real_name)>0 )
	{
		$data['real_name'] = $real_name;
	}
	$admin_index_obj->updateAdminIndex($data, "admin_id='{$_ADMIN_ID}'");
	tcmc_cls::ShowMsg("修改成功！", "user_set.php");
}


$smarty->assign('admin_info', $admin_info);
$smarty->display('user_set.tpl');